package com.legendshop.openportal.sdk.registry;

import com.legendshop.openportal.sdk.client.OpenClient;
import com.legendshop.openportal.sdk.client.OpenClientImpl;

/**
 * @author jzh
 * @version 1.0.0
 * @title OpenClientRegistry
 * @date 2024/6/18 17:58
 * @description：客户端注册器
 */
public class OpenClientRegistry {

    private static volatile OpenClient openClient;

    /**
     * 注册用户自定义客户端
     * @param openClient
     */
    public static void registerClient(final OpenClient openClient) {
        OpenClientRegistry.openClient = openClient;
    }

    /**
     * 获取客户端
     * @return
     */
    public static OpenClient getOpenClient() {
        if (openClient == null) {
            synchronized (OpenClientRegistry.class) {
                if (openClient == null) {
                    openClient = new OpenClientImpl();
                }
            }
        }
        return openClient;
    }
}
